{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import confusion_matrix\n",
    "from sklearn.metrics import roc_auc_score, auc\n",
    "from sklearn.metrics import precision_recall_curve\n",
    "from sklearn.metrics import classification_report\n",
    "from collections import Counter\n",
    "import re\n",
    "from tqdm import trange"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "pwd = 'D:/小麦/MDA-GCNFTG-main/MDA-GCNFTG-main/data/'\n",
    "peco_id_name = pd.read_excel(pwd + 'peco_name.xlsx')\n",
    "gene_id_name = pd.read_excel(pwd + 'gene_name.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def metrics(y_true, y_pred, y_prob):\n",
    "\n",
    "    tn, fp, fn, tp = confusion_matrix(y_true, y_pred).ravel()\n",
    "\n",
    "    pos_acc = tp / sum(y_true)\n",
    "    neg_acc = tn / (len(y_pred) - sum(y_pred)) # [y_true=0 & y_pred=0] / y_pred=0\n",
    "    accuracy = (tp+tn)/(tn+fp+fn+tp)\n",
    "    \n",
    "    recall = tp / (tp+fn)\n",
    "    precision = tp / (tp+fp)\n",
    "    f1 = 2*precision*recall / (precision+recall)\n",
    "    \n",
    "    roc_auc = roc_auc_score(y_true, y_prob)\n",
    "    prec, reca, _ = precision_recall_curve(y_true, y_prob)\n",
    "    aupr = auc(reca, prec)\n",
    "    average1 = (accuracy + precision + recall + roc_auc + aupr) / 5\n",
    "    average2 = (accuracy + f1 + roc_auc + aupr) / 4\n",
    "    average3 = (f1 + aupr) / 2\n",
    "    print('tn = {}, fp = {}, fn = {}, tp = {}'.format(tn, fp, fn, tp))\n",
    "    print('y_pred: 0 = {} | 1 = {}'.format(Counter(y_pred)[0], Counter(y_pred)[1]))\n",
    "    print('y_true: 0 = {} | 1 = {}'.format(Counter(y_true)[0], Counter(y_true)[1]))\n",
    "    print('acc={:.4f}|precision={:.4f}|recall={:.4f}|f1={:.4f}|auc={:.4f}|aupr={:.4f}|pos_acc={:.4f}|neg_acc={:.4f}'.format(accuracy, precision, recall, f1, roc_auc, aupr, pos_acc, neg_acc))\n",
    "    print('{:.4f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}, {:.4f}'.format(accuracy, precision, recall, f1, roc_auc, aupr, average1, average2, average3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def train_test_file(task, balance):\n",
    "    train_test_id_idx = np.load('D:/小麦/MDA-GCNFTG-main/MDA-GCNFTG-main/data/task_Tp__testlabel0_knn_edge_train_test_index_all.npz', allow_pickle = True)\n",
    "    train_index_all = train_test_id_idx['train_index_all']\n",
    "    test_index_all = train_test_id_idx['test_index_all']\n",
    "    train_id_all = train_test_id_idx['train_id_all'] # 'gene', 'peco'\n",
    "    test_id_all = train_test_id_idx['test_id_all'] # 'gene', 'peco'\n",
    "    return test_index_all, test_id_all, (train_index_all, train_id_all)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "def balanced_results_file(): #weight = None\n",
    "    file = np.load(\"D:\\小麦\\MDA-GCNFTG-main\\MDA-GCNFTG-main\\ys.npz\")\n",
    "    y_true_train, y_pred_train, y_prob_train = file['arr_1'][0], file['arr_1'][1], file['arr_1'][2]\n",
    "    y_true_test, y_pred_test, y_prob_test = file['arr_0'][0], file['arr_0'][1], file['arr_0'][2] \n",
    "    \n",
    "    print('Train:')\n",
    "    metrics(y_true_train, y_pred_train, y_prob_train)\n",
    "    print('Test:')\n",
    "    metrics(y_true_test, y_pred_test, y_prob_test)\n",
    "    \n",
    "    return y_true_test, y_pred_test, y_prob_test, (y_true_train, y_pred_train, y_prob_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sample(random_seed):\n",
    "    all_associations = pd.read_csv('D:/小麦/MDA-GCNFTG-main/MDA-GCNFTG-main/data/all_gpe_pairs.csv', names=['gene', 'disease', 'label'])\n",
    "    known_associations = all_associations.loc[all_associations['label'] == 1]\n",
    "    unknown_associations = all_associations.loc[all_associations['label'] == 0]\n",
    "    random_negative = unknown_associations.sample(n=known_associations.shape[0], random_state=random_seed, axis=0)\n",
    "\n",
    "    sample_df = known_associations.append(random_negative)\n",
    "    sample_df.reset_index(drop=True, inplace=True)\n",
    "\n",
    "    return sample_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def run_balanced_Tp(task, balance, knn, lr):\n",
    "    test_index_all, test_id_all, _ = train_test_file(task, balance)# '__nobalance'\n",
    "\n",
    "    for i in range(5):\n",
    "        print('==== Fold ', i)\n",
    "        y_true_test, y_pred_test, y_prob_test, _ = balanced_results_file()\n",
    "\n",
    "        if i == 0:\n",
    "             y_true_test_all, y_pred_test_all, y_prob_test_all = y_true_test, y_pred_test, y_prob_test\n",
    "        else:\n",
    "            y_true_test_all = np.vstack([y_true_test_all, y_true_test])\n",
    "            y_pred_test_all = np.vstack([y_pred_test_all, y_pred_test])\n",
    "            y_prob_test_all = np.vstack([y_prob_test_all, y_prob_test])\n",
    "            assert (y_prob_test_all[i] == y_prob_test).all()\n",
    "\n",
    "    results_df = pd.DataFrame(test_id_all.reshape(-1, 2), columns = ['gene', 'peco'])\n",
    "    results_df['y_true'] = y_true_test_all.reshape(-1)\n",
    "    results_df['y_pred'] = y_pred_test_all.reshape(-1)\n",
    "    results_df['y_prob'] = y_prob_test_all.reshape(-1)\n",
    "\n",
    "    results_df = pd.merge(results_df, gene_id_name, left_on = 'gene', right_on = 'id')\n",
    "    results_df = pd.merge(results_df, peco_id_name, left_on = 'peco', right_on = 'id')\n",
    "    results_df.drop(labels = ['id_x', 'id_y'], axis = 1, inplace = True)\n",
    "    results_df.sort_values(by = ['peco_x', 'y_prob'], ascending = False, inplace = True)\n",
    "    \n",
    "    results_df.to_csv(task + '_balanced_case_study_0.csv')\n",
    "    \n",
    "    return results_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def run_balanced_Tgp(task, balance, knn, lr):\n",
    "    dtp = sample(random_seed = 1234)\n",
    "    test_index_all, test_id_all, _ = train_test_file(task, balance)# '__nobalance'\n",
    "\n",
    "    for i in range(5):\n",
    "        print('==== Fold ', i)\n",
    "        y_true_test, y_pred_test, y_prob_test, _ = balanced_results_file(task, knn, lr, fold = i)\n",
    "\n",
    "        temp = dtp.iloc[test_index_all[i]][['gene', 'peco']]\n",
    "        if i == 0:\n",
    "            y_true_test_all, y_pred_test_all, y_prob_test_all = y_true_test, y_pred_test, y_prob_test\n",
    "            \n",
    "            results_df = temp\n",
    "        else:\n",
    "            y_true_test_all = np.hstack([y_true_test_all, y_true_test])\n",
    "            y_pred_test_all = np.hstack([y_pred_test_all, y_pred_test])\n",
    "            y_prob_test_all = np.hstack([y_prob_test_all, y_prob_test])\n",
    "            \n",
    "            results_df = pd.concat([results_df, temp], axis = 0)\n",
    "            \n",
    "    results_df['y_true'] = y_true_test_all.reshape(-1)\n",
    "    results_df['y_pred'] = y_pred_test_all.reshape(-1)\n",
    "    results_df['y_prob'] = y_prob_test_all.reshape(-1)\n",
    "\n",
    "    results_df = pd.merge(results_df, gene_id_name, left_on = 'gene', right_on = 'id')\n",
    "    results_df = pd.merge(results_df, peco_id_name, left_on = 'peco', right_on = 'id')\n",
    "    results_df.drop(labels = ['id_x', 'id_y'], axis = 1, inplace = True)\n",
    "    results_df.sort_values(by = ['peco_x', 'y_prob'], ascending = False, inplace = True)\n",
    "    \n",
    "    results_df.to_csv(task + '_balanced_case_study_0.csv')\n",
    "    \n",
    "    return results_df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Run balanced"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==== Fold  0\n",
      "Train:\n",
      "tn = 2366, fp = 5, fn = 20, tp = 2382\n",
      "y_pred: 0 = 2386 | 1 = 2387\n",
      "y_true: 0 = 2371 | 1 = 2402\n",
      "acc=0.9948|precision=0.9979|recall=0.9917|f1=0.9948|auc=0.9999|aupr=0.9999|pos_acc=0.9917|neg_acc=0.9916\n",
      "0.9948, 0.9979, 0.9917, 0.9948, 0.9999, 0.9999, 0.9968, 0.9973, 0.9973\n",
      "Test:\n",
      "tn = 1080, fp = 14, fn = 26, tp = 1052\n",
      "y_pred: 0 = 1106 | 1 = 1066\n",
      "y_true: 0 = 1094 | 1 = 1078\n",
      "acc=0.9816|precision=0.9869|recall=0.9759|f1=0.9813|auc=0.9972|aupr=0.9976|pos_acc=0.9759|neg_acc=0.9765\n",
      "0.9816, 0.9869, 0.9759, 0.9813, 0.9972, 0.9976, 0.9878, 0.9894, 0.9895\n",
      "==== Fold  1\n",
      "Train:\n",
      "tn = 2424, fp = 3, fn = 7, tp = 2346\n",
      "y_pred: 0 = 2431 | 1 = 2349\n",
      "y_true: 0 = 2427 | 1 = 2353\n",
      "acc=0.9979|precision=0.9987|recall=0.9970|f1=0.9979|auc=1.0000|aupr=1.0000|pos_acc=0.9970|neg_acc=0.9971\n",
      "0.9979, 0.9987, 0.9970, 0.9979, 1.0000, 1.0000, 0.9987, 0.9989, 0.9989\n",
      "Test:\n",
      "tn = 1075, fp = 21, fn = 20, tp = 1056\n",
      "y_pred: 0 = 1095 | 1 = 1077\n",
      "y_true: 0 = 1096 | 1 = 1076\n",
      "acc=0.9811|precision=0.9805|recall=0.9814|f1=0.9810|auc=0.9973|aupr=0.9977|pos_acc=0.9814|neg_acc=0.9817\n",
      "0.9811, 0.9805, 0.9814, 0.9810, 0.9973, 0.9977, 0.9876, 0.9893, 0.9893\n",
      "==== Fold  2\n",
      "Train:\n",
      "tn = 2352, fp = 2, fn = 11, tp = 2408\n",
      "y_pred: 0 = 2363 | 1 = 2410\n",
      "y_true: 0 = 2354 | 1 = 2419\n",
      "acc=0.9973|precision=0.9992|recall=0.9955|f1=0.9973|auc=1.0000|aupr=1.0000|pos_acc=0.9955|neg_acc=0.9953\n",
      "0.9973, 0.9992, 0.9955, 0.9973, 1.0000, 1.0000, 0.9984, 0.9986, 0.9986\n",
      "Test:\n",
      "tn = 1073, fp = 12, fn = 24, tp = 1063\n",
      "y_pred: 0 = 1097 | 1 = 1075\n",
      "y_true: 0 = 1085 | 1 = 1087\n",
      "acc=0.9834|precision=0.9888|recall=0.9779|f1=0.9833|auc=0.9975|aupr=0.9978|pos_acc=0.9779|neg_acc=0.9781\n",
      "0.9834, 0.9888, 0.9779, 0.9833, 0.9975, 0.9978, 0.9891, 0.9905, 0.9906\n",
      "==== Fold  3\n",
      "Train:\n",
      "tn = 2414, fp = 5, fn = 8, tp = 2301\n",
      "y_pred: 0 = 2422 | 1 = 2306\n",
      "y_true: 0 = 2419 | 1 = 2309\n",
      "acc=0.9973|precision=0.9978|recall=0.9965|f1=0.9972|auc=1.0000|aupr=1.0000|pos_acc=0.9965|neg_acc=0.9967\n",
      "0.9973, 0.9978, 0.9965, 0.9972, 1.0000, 1.0000, 0.9983, 0.9986, 0.9986\n",
      "Test:\n",
      "tn = 1052, fp = 11, fn = 22, tp = 1087\n",
      "y_pred: 0 = 1074 | 1 = 1098\n",
      "y_true: 0 = 1063 | 1 = 1109\n",
      "acc=0.9848|precision=0.9900|recall=0.9802|f1=0.9850|auc=0.9977|aupr=0.9981|pos_acc=0.9802|neg_acc=0.9795\n",
      "0.9848, 0.9900, 0.9802, 0.9850, 0.9977, 0.9981, 0.9902, 0.9914, 0.9916\n",
      "==== Fold  4\n",
      "Train:\n",
      "tn = 2414, fp = 5, fn = 12, tp = 2342\n",
      "y_pred: 0 = 2426 | 1 = 2347\n",
      "y_true: 0 = 2419 | 1 = 2354\n",
      "acc=0.9964|precision=0.9979|recall=0.9949|f1=0.9964|auc=1.0000|aupr=1.0000|pos_acc=0.9949|neg_acc=0.9951\n",
      "0.9964, 0.9979, 0.9949, 0.9964, 1.0000, 1.0000, 0.9978, 0.9982, 0.9982\n",
      "Test:\n",
      "tn = 1073, fp = 19, fn = 29, tp = 1051\n",
      "y_pred: 0 = 1102 | 1 = 1070\n",
      "y_true: 0 = 1092 | 1 = 1080\n",
      "acc=0.9779|precision=0.9822|recall=0.9731|f1=0.9777|auc=0.9970|aupr=0.9974|pos_acc=0.9731|neg_acc=0.9737\n",
      "0.9779, 0.9822, 0.9731, 0.9777, 0.9970, 0.9974, 0.9855, 0.9875, 0.9875\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>miRNA_x</th>\n",
       "      <th>disease_x</th>\n",
       "      <th>y_true</th>\n",
       "      <th>y_pred</th>\n",
       "      <th>y_prob</th>\n",
       "      <th>miRNA_y</th>\n",
       "      <th>disease_y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>7250</th>\n",
       "      <td>14</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999627</td>\n",
       "      <td>hsa-mir-21</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7253</th>\n",
       "      <td>116</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999554</td>\n",
       "      <td>hsa-mir-483</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7249</th>\n",
       "      <td>10</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999477</td>\n",
       "      <td>hsa-mir-145</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7258</th>\n",
       "      <td>148</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.996552</td>\n",
       "      <td>hsa-mir-9</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7248</th>\n",
       "      <td>9</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.996511</td>\n",
       "      <td>hsa-mir-143</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>327</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000531</td>\n",
       "      <td>hsa-mir-512</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>164</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000500</td>\n",
       "      <td>hsa-let-7i</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>108</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000489</td>\n",
       "      <td>hsa-mir-942</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>371</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000476</td>\n",
       "      <td>hsa-mir-1275</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000468</td>\n",
       "      <td>hsa-mir-1246</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10860 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      miRNA_x  disease_x  y_true  y_pred    y_prob       miRNA_y  \\\n",
       "7250       14        383     1.0     1.0  0.999627    hsa-mir-21   \n",
       "7253      116        383     1.0     1.0  0.999554   hsa-mir-483   \n",
       "7249       10        383     1.0     1.0  0.999477   hsa-mir-145   \n",
       "7258      148        383     1.0     1.0  0.996552     hsa-mir-9   \n",
       "7248        9        383     1.0     1.0  0.996511   hsa-mir-143   \n",
       "...       ...        ...     ...     ...       ...           ...   \n",
       "12        327          1     0.0     0.0  0.000531   hsa-mir-512   \n",
       "10        164          1     0.0     0.0  0.000500    hsa-let-7i   \n",
       "9         108          1     0.0     0.0  0.000489   hsa-mir-942   \n",
       "13        371          1     0.0     0.0  0.000476  hsa-mir-1275   \n",
       "6          63          1     0.0     0.0  0.000468  hsa-mir-1246   \n",
       "\n",
       "                    disease_y  \n",
       "7250  ['Wounds and Injuries']  \n",
       "7253  ['Wounds and Injuries']  \n",
       "7249  ['Wounds and Injuries']  \n",
       "7258  ['Wounds and Injuries']  \n",
       "7248  ['Wounds and Injuries']  \n",
       "...                       ...  \n",
       "12     ['Abortion, Habitual']  \n",
       "10     ['Abortion, Habitual']  \n",
       "9      ['Abortion, Habitual']  \n",
       "13     ['Abortion, Habitual']  \n",
       "6      ['Abortion, Habitual']  \n",
       "\n",
       "[10860 rows x 7 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_Tp_balanced = run_balanced_Tp(task = 'Tp', balance = '', knn = '10knn', lr = 0.001)\n",
    "results_Tp_balanced"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==== Fold  0\n",
      "Train:\n",
      "tn = 2283, fp = 9, fn = 16, tp = 2349\n",
      "y_pred: 0 = 2299 | 1 = 2358\n",
      "y_true: 0 = 2292 | 1 = 2365\n",
      "acc=0.9946|precision=0.9962|recall=0.9932|f1=0.9947|auc=0.9999|aupr=0.9999|pos_acc=0.9932|neg_acc=0.9930\n",
      "0.9946, 0.9962, 0.9932, 0.9947, 0.9999, 0.9999, 0.9968, 0.9973, 0.9973\n",
      "Test:\n",
      "tn = 1093, fp = 10, fn = 32, tp = 887\n",
      "y_pred: 0 = 1125 | 1 = 897\n",
      "y_true: 0 = 1103 | 1 = 919\n",
      "acc=0.9792|precision=0.9889|recall=0.9652|f1=0.9769|auc=0.9941|aupr=0.9945|pos_acc=0.9652|neg_acc=0.9716\n",
      "0.9792, 0.9889, 0.9652, 0.9769, 0.9941, 0.9945, 0.9844, 0.9862, 0.9857\n",
      "==== Fold  1\n",
      "Train:\n",
      "tn = 2292, fp = 5, fn = 9, tp = 2369\n",
      "y_pred: 0 = 2301 | 1 = 2374\n",
      "y_true: 0 = 2297 | 1 = 2378\n",
      "acc=0.9970|precision=0.9979|recall=0.9962|f1=0.9971|auc=1.0000|aupr=1.0000|pos_acc=0.9962|neg_acc=0.9961\n",
      "0.9970, 0.9979, 0.9962, 0.9971, 1.0000, 1.0000, 0.9982, 0.9985, 0.9985\n",
      "Test:\n",
      "tn = 1097, fp = 7, fn = 72, tp = 850\n",
      "y_pred: 0 = 1169 | 1 = 857\n",
      "y_true: 0 = 1104 | 1 = 922\n",
      "acc=0.9610|precision=0.9918|recall=0.9219|f1=0.9556|auc=0.9834|aupr=0.9851|pos_acc=0.9219|neg_acc=0.9384\n",
      "0.9610, 0.9918, 0.9219, 0.9556, 0.9834, 0.9851, 0.9686, 0.9713, 0.9704\n",
      "==== Fold  2\n",
      "Train:\n",
      "tn = 2359, fp = 6, fn = 11, tp = 2218\n",
      "y_pred: 0 = 2370 | 1 = 2224\n",
      "y_true: 0 = 2365 | 1 = 2229\n",
      "acc=0.9963|precision=0.9973|recall=0.9951|f1=0.9962|auc=0.9999|aupr=0.9999|pos_acc=0.9951|neg_acc=0.9954\n",
      "0.9963, 0.9973, 0.9951, 0.9962, 0.9999, 0.9999, 0.9977, 0.9981, 0.9981\n",
      "Test:\n",
      "tn = 1043, fp = 14, fn = 89, tp = 1017\n",
      "y_pred: 0 = 1132 | 1 = 1031\n",
      "y_true: 0 = 1057 | 1 = 1106\n",
      "acc=0.9524|precision=0.9864|recall=0.9195|f1=0.9518|auc=0.9822|aupr=0.9867|pos_acc=0.9195|neg_acc=0.9214\n",
      "0.9524, 0.9864, 0.9195, 0.9518, 0.9822, 0.9867, 0.9654, 0.9683, 0.9693\n",
      "==== Fold  3\n",
      "Train:\n",
      "tn = 2342, fp = 9, fn = 6, tp = 2204\n",
      "y_pred: 0 = 2348 | 1 = 2213\n",
      "y_true: 0 = 2351 | 1 = 2210\n",
      "acc=0.9967|precision=0.9959|recall=0.9973|f1=0.9966|auc=1.0000|aupr=1.0000|pos_acc=0.9973|neg_acc=0.9974\n",
      "0.9967, 0.9959, 0.9973, 0.9966, 1.0000, 1.0000, 0.9980, 0.9983, 0.9983\n",
      "Test:\n",
      "tn = 1079, fp = 14, fn = 133, tp = 1103\n",
      "y_pred: 0 = 1212 | 1 = 1117\n",
      "y_true: 0 = 1093 | 1 = 1236\n",
      "acc=0.9369|precision=0.9875|recall=0.8924|f1=0.9375|auc=0.9822|aupr=0.9867|pos_acc=0.8924|neg_acc=0.8903\n",
      "0.9369, 0.9875, 0.8924, 0.9375, 0.9822, 0.9867, 0.9571, 0.9608, 0.9621\n",
      "==== Fold  4\n",
      "Train:\n",
      "tn = 2398, fp = 0, fn = 16, tp = 2164\n",
      "y_pred: 0 = 2414 | 1 = 2164\n",
      "y_true: 0 = 2398 | 1 = 2180\n",
      "acc=0.9965|precision=1.0000|recall=0.9927|f1=0.9963|auc=0.9998|aupr=0.9998|pos_acc=0.9927|neg_acc=0.9934\n",
      "0.9965, 1.0000, 0.9927, 0.9963, 0.9998, 0.9998, 0.9977, 0.9981, 0.9980\n",
      "Test:\n",
      "tn = 1067, fp = 6, fn = 67, tp = 1180\n",
      "y_pred: 0 = 1134 | 1 = 1186\n",
      "y_true: 0 = 1073 | 1 = 1247\n",
      "acc=0.9685|precision=0.9949|recall=0.9463|f1=0.9700|auc=0.9848|aupr=0.9900|pos_acc=0.9463|neg_acc=0.9409\n",
      "0.9685, 0.9949, 0.9463, 0.9700, 0.9848, 0.9900, 0.9769, 0.9783, 0.9800\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>miRNA_x</th>\n",
       "      <th>disease_x</th>\n",
       "      <th>y_true</th>\n",
       "      <th>y_pred</th>\n",
       "      <th>y_prob</th>\n",
       "      <th>miRNA_y</th>\n",
       "      <th>disease_y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9224</th>\n",
       "      <td>148</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999978</td>\n",
       "      <td>hsa-mir-9</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9226</th>\n",
       "      <td>9</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999975</td>\n",
       "      <td>hsa-mir-143</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9223</th>\n",
       "      <td>116</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999960</td>\n",
       "      <td>hsa-mir-483</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9231</th>\n",
       "      <td>10</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999892</td>\n",
       "      <td>hsa-mir-145</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9237</th>\n",
       "      <td>14</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999791</td>\n",
       "      <td>hsa-mir-21</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1402</th>\n",
       "      <td>24</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000030</td>\n",
       "      <td>hsa-mir-126</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1393</th>\n",
       "      <td>108</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000026</td>\n",
       "      <td>hsa-mir-942</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1390</th>\n",
       "      <td>164</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000025</td>\n",
       "      <td>hsa-let-7i</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1405</th>\n",
       "      <td>327</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000025</td>\n",
       "      <td>hsa-mir-512</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1391</th>\n",
       "      <td>482</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.000024</td>\n",
       "      <td>hsa-mir-570</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10860 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      miRNA_x  disease_x  y_true  y_pred    y_prob      miRNA_y  \\\n",
       "9224      148        383     1.0     1.0  0.999978    hsa-mir-9   \n",
       "9226        9        383     1.0     1.0  0.999975  hsa-mir-143   \n",
       "9223      116        383     1.0     1.0  0.999960  hsa-mir-483   \n",
       "9231       10        383     1.0     1.0  0.999892  hsa-mir-145   \n",
       "9237       14        383     1.0     1.0  0.999791   hsa-mir-21   \n",
       "...       ...        ...     ...     ...       ...          ...   \n",
       "1402       24          1     0.0     0.0  0.000030  hsa-mir-126   \n",
       "1393      108          1     0.0     0.0  0.000026  hsa-mir-942   \n",
       "1390      164          1     0.0     0.0  0.000025   hsa-let-7i   \n",
       "1405      327          1     0.0     0.0  0.000025  hsa-mir-512   \n",
       "1391      482          1     0.0     0.0  0.000024  hsa-mir-570   \n",
       "\n",
       "                    disease_y  \n",
       "9224  ['Wounds and Injuries']  \n",
       "9226  ['Wounds and Injuries']  \n",
       "9223  ['Wounds and Injuries']  \n",
       "9231  ['Wounds and Injuries']  \n",
       "9237  ['Wounds and Injuries']  \n",
       "...                       ...  \n",
       "1402   ['Abortion, Habitual']  \n",
       "1393   ['Abortion, Habitual']  \n",
       "1390   ['Abortion, Habitual']  \n",
       "1405   ['Abortion, Habitual']  \n",
       "1391   ['Abortion, Habitual']  \n",
       "\n",
       "[10860 rows x 7 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_Tm_balanced = run_balanced_Tmd(task = 'Tm', balance = '', knn = '7knn', lr = 0.01)\n",
    "results_Tm_balanced"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==== Fold  0\n",
      "Train:\n",
      "tn = 2249, fp = 4, fn = 10, tp = 2162\n",
      "y_pred: 0 = 2259 | 1 = 2166\n",
      "y_true: 0 = 2253 | 1 = 2172\n",
      "acc=0.9968|precision=0.9982|recall=0.9954|f1=0.9968|auc=1.0000|aupr=1.0000|pos_acc=0.9954|neg_acc=0.9956\n",
      "0.9968, 0.9982, 0.9954, 0.9968, 1.0000, 1.0000, 0.9981, 0.9984, 0.9984\n",
      "Test:\n",
      "tn = 1078, fp = 12, fn = 25, tp = 1119\n",
      "y_pred: 0 = 1103 | 1 = 1131\n",
      "y_true: 0 = 1090 | 1 = 1144\n",
      "acc=0.9834|precision=0.9894|recall=0.9781|f1=0.9837|auc=0.9974|aupr=0.9979|pos_acc=0.9781|neg_acc=0.9773\n",
      "0.9834, 0.9894, 0.9781, 0.9837, 0.9974, 0.9979, 0.9893, 0.9906, 0.9908\n",
      "==== Fold  1\n",
      "Train:\n",
      "tn = 2187, fp = 2, fn = 13, tp = 2354\n",
      "y_pred: 0 = 2200 | 1 = 2356\n",
      "y_true: 0 = 2189 | 1 = 2367\n",
      "acc=0.9967|precision=0.9992|recall=0.9945|f1=0.9968|auc=1.0000|aupr=1.0000|pos_acc=0.9945|neg_acc=0.9941\n",
      "0.9967, 0.9992, 0.9945, 0.9968, 1.0000, 1.0000, 0.9981, 0.9984, 0.9984\n",
      "Test:\n",
      "tn = 997, fp = 26, fn = 13, tp = 722\n",
      "y_pred: 0 = 1010 | 1 = 748\n",
      "y_true: 0 = 1023 | 1 = 735\n",
      "acc=0.9778|precision=0.9652|recall=0.9823|f1=0.9737|auc=0.9974|aupr=0.9973|pos_acc=0.9823|neg_acc=0.9871\n",
      "0.9778, 0.9652, 0.9823, 0.9737, 0.9974, 0.9973, 0.9840, 0.9866, 0.9855\n",
      "==== Fold  2\n",
      "Train:\n",
      "tn = 2244, fp = 8, fn = 8, tp = 2076\n",
      "y_pred: 0 = 2252 | 1 = 2084\n",
      "y_true: 0 = 2252 | 1 = 2084\n",
      "acc=0.9963|precision=0.9962|recall=0.9962|f1=0.9962|auc=1.0000|aupr=1.0000|pos_acc=0.9962|neg_acc=0.9964\n",
      "0.9963, 0.9962, 0.9962, 0.9962, 1.0000, 1.0000, 0.9977, 0.9981, 0.9981\n",
      "Test:\n",
      "tn = 1078, fp = 14, fn = 30, tp = 1259\n",
      "y_pred: 0 = 1108 | 1 = 1273\n",
      "y_true: 0 = 1092 | 1 = 1289\n",
      "acc=0.9815|precision=0.9890|recall=0.9767|f1=0.9828|auc=0.9972|aupr=0.9980|pos_acc=0.9767|neg_acc=0.9729\n",
      "0.9815, 0.9890, 0.9767, 0.9828, 0.9972, 0.9980, 0.9885, 0.9899, 0.9904\n",
      "==== Fold  3\n",
      "Train:\n",
      "tn = 2218, fp = 3, fn = 12, tp = 2189\n",
      "y_pred: 0 = 2230 | 1 = 2192\n",
      "y_true: 0 = 2221 | 1 = 2201\n",
      "acc=0.9966|precision=0.9986|recall=0.9945|f1=0.9966|auc=1.0000|aupr=1.0000|pos_acc=0.9945|neg_acc=0.9946\n",
      "0.9966, 0.9986, 0.9945, 0.9966, 1.0000, 1.0000, 0.9979, 0.9983, 0.9983\n",
      "Test:\n",
      "tn = 1085, fp = 12, fn = 24, tp = 1235\n",
      "y_pred: 0 = 1109 | 1 = 1247\n",
      "y_true: 0 = 1097 | 1 = 1259\n",
      "acc=0.9847|precision=0.9904|recall=0.9809|f1=0.9856|auc=0.9966|aupr=0.9975|pos_acc=0.9809|neg_acc=0.9784\n",
      "0.9847, 0.9904, 0.9809, 0.9856, 0.9966, 0.9975, 0.9900, 0.9911, 0.9916\n",
      "==== Fold  4\n",
      "Train:\n",
      "tn = 2191, fp = 6, fn = 15, tp = 2229\n",
      "y_pred: 0 = 2206 | 1 = 2235\n",
      "y_true: 0 = 2197 | 1 = 2244\n",
      "acc=0.9953|precision=0.9973|recall=0.9933|f1=0.9953|auc=0.9999|aupr=0.9999|pos_acc=0.9933|neg_acc=0.9932\n",
      "0.9953, 0.9973, 0.9933, 0.9953, 0.9999, 0.9999, 0.9972, 0.9976, 0.9976\n",
      "Test:\n",
      "tn = 1124, fp = 4, fn = 41, tp = 962\n",
      "y_pred: 0 = 1165 | 1 = 966\n",
      "y_true: 0 = 1128 | 1 = 1003\n",
      "acc=0.9789|precision=0.9959|recall=0.9591|f1=0.9771|auc=0.9961|aupr=0.9964|pos_acc=0.9591|neg_acc=0.9648\n",
      "0.9789, 0.9959, 0.9591, 0.9771, 0.9961, 0.9964, 0.9853, 0.9871, 0.9868\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>miRNA_x</th>\n",
       "      <th>disease_x</th>\n",
       "      <th>y_true</th>\n",
       "      <th>y_pred</th>\n",
       "      <th>y_prob</th>\n",
       "      <th>miRNA_y</th>\n",
       "      <th>disease_y</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8048</th>\n",
       "      <td>116</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999104</td>\n",
       "      <td>hsa-mir-483</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8049</th>\n",
       "      <td>9</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999097</td>\n",
       "      <td>hsa-mir-143</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8037</th>\n",
       "      <td>148</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999097</td>\n",
       "      <td>hsa-mir-9</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8036</th>\n",
       "      <td>14</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.999079</td>\n",
       "      <td>hsa-mir-21</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8034</th>\n",
       "      <td>10</td>\n",
       "      <td>383</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.998415</td>\n",
       "      <td>hsa-mir-145</td>\n",
       "      <td>['Wounds and Injuries']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8554</th>\n",
       "      <td>482</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001152</td>\n",
       "      <td>hsa-mir-570</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8543</th>\n",
       "      <td>24</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001151</td>\n",
       "      <td>hsa-mir-126</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8551</th>\n",
       "      <td>164</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001149</td>\n",
       "      <td>hsa-let-7i</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8553</th>\n",
       "      <td>454</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001148</td>\n",
       "      <td>hsa-mir-767</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8552</th>\n",
       "      <td>63</td>\n",
       "      <td>1</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.001148</td>\n",
       "      <td>hsa-mir-1246</td>\n",
       "      <td>['Abortion, Habitual']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10860 rows × 7 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      miRNA_x  disease_x  y_true  y_pred    y_prob       miRNA_y  \\\n",
       "8048      116        383     1.0     1.0  0.999104   hsa-mir-483   \n",
       "8049        9        383     1.0     1.0  0.999097   hsa-mir-143   \n",
       "8037      148        383     1.0     1.0  0.999097     hsa-mir-9   \n",
       "8036       14        383     1.0     1.0  0.999079    hsa-mir-21   \n",
       "8034       10        383     1.0     1.0  0.998415   hsa-mir-145   \n",
       "...       ...        ...     ...     ...       ...           ...   \n",
       "8554      482          1     0.0     0.0  0.001152   hsa-mir-570   \n",
       "8543       24          1     0.0     0.0  0.001151   hsa-mir-126   \n",
       "8551      164          1     0.0     0.0  0.001149    hsa-let-7i   \n",
       "8553      454          1     0.0     0.0  0.001148   hsa-mir-767   \n",
       "8552       63          1     0.0     0.0  0.001148  hsa-mir-1246   \n",
       "\n",
       "                    disease_y  \n",
       "8048  ['Wounds and Injuries']  \n",
       "8049  ['Wounds and Injuries']  \n",
       "8037  ['Wounds and Injuries']  \n",
       "8036  ['Wounds and Injuries']  \n",
       "8034  ['Wounds and Injuries']  \n",
       "...                       ...  \n",
       "8554   ['Abortion, Habitual']  \n",
       "8543   ['Abortion, Habitual']  \n",
       "8551   ['Abortion, Habitual']  \n",
       "8553   ['Abortion, Habitual']  \n",
       "8552   ['Abortion, Habitual']  \n",
       "\n",
       "[10860 rows x 7 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "results_Td_balanced = run_balanced_Tmd(task = 'Td', balance = '', knn = '5knn', lr = 0.001)\n",
    "results_Td_balanced"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['arr_0', 'arr_1']\n",
      "(3, 2871)\n",
      "(3, 9424)\n"
     ]
    }
   ],
   "source": [
    "datas = np.load(\"D:\\小麦\\MDA-GCNFTG-main\\MDA-GCNFTG-main\\ys.npz\")\n",
    "print(datas.files)\n",
    "a = datas['arr_0']\n",
    "b = datas['arr_1']\n",
    "print(a.shape)\n",
    "print(b.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "495"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "13+482"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "495"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "28+467"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "495"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "24+471"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
